package com.xueyi.tesla.entity.dto;

import com.xueyi.core.utils.MD5Utils;
import com.xueyi.game.backend.entity.po.BaseUser;
import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

/**
 * 描述 保存用户
 *
 * @auther 俞烨
 * @date 2022-11-08 19
 */
public class SaveBaseUserDto extends BaseUser {

    private Integer id;


    @NotBlank(message = "账号不能为空")
    @Size(min = 10, max = 20, message = "账号长度为10~20位")
    @Pattern(regexp = "^[a-zA-Z0-9]{10,20}$",
            message = "账号字母和数字组成")
    private String account;

    @Size(min = 16, max = 32, message = "密码长度在16~32位之间")
    @Pattern(regexp = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[!@#$%^&*(),.?\":{}|<>]).{16,32}$",
            message = "密码的长度在16~32位，包含大小写字母，特殊字符，加数字")
    private String password;

    @NotBlank(message = "图片不能为空")
    private String uPhoto;

    @NotBlank(message = "手机号不能为空")
    @Size(min = 11, max = 11, message = "手机号不合法")
    @Pattern(regexp = "^[0-9]{11}$",
            message = "手机号不合法")
    private String uPhone;

    @NotBlank(message = "角色id不能为空")
    private String roleIds;


    @NotBlank(message = "昵称不能为空")
    private String uName;

    public String getuName() {
        return uName;
    }

    public void setuName(String uName) {
        this.uName = uName;
    }

    @Override
    public Integer getId() {
        return id;
    }

    @Override
    public void setId(Integer id) {
        this.id = id;
    }

    @Override
    public String getAccount() {
        return account;
    }

    @Override
    public void setAccount(String account) {
        this.account = account;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public void setPassword(String password) {
        this.password = password;
    }

    public String getuPhoto() {
        return uPhoto;
    }

    public void setuPhoto(String uPhoto) {
        this.uPhoto = uPhoto;
    }

    @Override
    public String getuPhone() {
        return uPhone;
    }

    @Override
    public void setuPhone(String uPhone) {
        this.uPhone = uPhone;
    }

    public String getRoleIds() {
        return roleIds;
    }

    public void setRoleIds(String roleIds) {
        this.roleIds = roleIds;
    }

    public void check() {
        password = StringUtils.isBlank(password) ? null : MD5Utils.md5(password.trim());
    }
}
